<?php
/*
+--------------------------------------------------------------------------
|   AffiliStore 2
|   ========================================
|   Web: http://www.affilistore.com
|   Email: admin (at) affilistore (dot) com
|	License Type: AffiliStore 2 is NOT open source software and limitations apply 
|   Licence Info: Visit AffiliStore website and click on 'Licence'
+--------------------------------------------------------------------------
*/
if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) || eregi(".inc.php",$_SERVER['PHP_SELF'])) {
	echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
	exit;
}

$box_content = new XTemplate ("skins/".$configSkin['value']."/styleTemplates/pagination.tpl");

if ($totalRows_product > 0) {
	
	$totalPages_product = $totalPages_product+1;
	
		
	if ($pageNum_product < 3) {
	$pluspages = 3;
	} else if ($pageNum_product+3 > $totalPages_product) {
	$pluspages = $totalPages_product-2;
	} else {
	$pluspages = $pageNum_product+1;
	}
	
	//------------ begin switch page type options ------------//
	
	// ---------- prod category
	switch ($_GET['case']) {
	case "products":
	$box_content->assign("DATA",str_replace('-', ' ', $_GET['pc']));
		if ($navOpt[7] == 1) {
		// html perma
		$firstpage = '<a href="'.$installDir['value'].'productspage/1/'.$_GET['pc'].'.html">First</a> | ';
		$previouspage = '<a href="'.$installDir['value'].'productspage/'.max(1, $pageNum_product - 1).'/'.$_GET['pc'].'.html">Previous</a> | ';
		$nextpage = '<a href="'.$installDir['value'].'productspage/'.min($totalPages_product, $pageNum_product + 2).'/'.$_GET['pc'].'.html">Next</a> | ';
		$lastpage = '<a href="'.$installDir['value'].'productspage/'.$totalPages_product.'/'.$_GET['pc'].'.html">Last</a>';
			for ($i=$pluspages-2;$i<=$pluspages+2;$i++) {
				if ($i <= $totalPages_product && $i != 0) {
				$plusone .= '<a href="'.$installDir['value'].'productspage/'.min($totalPages_product, $i).'/'.$_GET['pc'].'.html">'.$i.'</a> | ';
				}
			}
		} else {
		// php link
		$firstpage = '<a href="'.$currentPage.'?pageNum_product=1'.$queryString_product.'">First</a> | ';
		$previouspage = '<a href="'.$currentPage.'?pageNum_product='.max(1, $pageNum_product - 1).$queryString_product.'">Previous</a> | ';
		$nextpage = '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $pageNum_product + 2).$queryString_product.'">Next</a> | ';
		$lastpage = '<a href="'.$currentPage.'?pageNum_product='.$totalPages_product.$queryString_product.'">Last</a>';
			for ($i=$pluspages-2;$i<=$pluspages+2;$i++) {
				if ($i <= $totalPages_product && $i != 0) {
				$plusone .= '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $i).$queryString_product.'">'.$i.'</a> | ';
				}
			}
		}
	break;
	
	// ---------- prod brand
	case "subproducts":
	$box_content->assign("DATA",str_replace('-', ' ', $_GET['pb']).' '.str_replace('-', ' ', $_GET['pc']));
		if ($navOpt[7] == 1) {
		// html perma
		$firstpage = '<a href="'.$installDir['value'].'subproductspage/1/'.$_GET['pc'].'/'.$_GET['pb'].'.html">First</a> | ';
		$previouspage = '<a href="'.$installDir['value'].'subproductspage/'.max(1, $pageNum_product - 1).'/'.$_GET['pc'].'/'.$_GET['pb'].'.html">Previous</a> | ';
		$nextpage = '<a href="'.$installDir['value'].'subproductspage/'.min($totalPages_product, $pageNum_product + 2).'/'.$_GET['pc'].'/'.$_GET['pb'].'.html">Next</a> | ';
		$lastpage = '<a href="'.$installDir['value'].'subproductspage/'.$totalPages_product.'/'.$_GET['pc'].'/'.$_GET['pb'].'.html">Last</a>';
			for ($i=$pluspages-2;$i<=$pluspages+2;$i++) {
				if ($i <= $totalPages_product && $i != 0) {
				$plusone .= '<a href="'.$installDir['value'].'subproductspage/'.min($totalPages_product, $i).'/'.$_GET['pc'].'/'.$_GET['pb'].'.html">'.$i.'</a> | ';
				}
			}
		} else {
		// php link
		$firstpage = '<a href="'.$currentPage.'?pageNum_product=1'.$queryString_product.'">First</a> | ';
		$previouspage = '<a href="'.$currentPage.'?pageNum_product='.max(1, $pageNum_product - 1).$queryString_product.'">Previous</a> | ';
		$nextpage = '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $pageNum_product + 2).$queryString_product.'">Next</a> | ';
		$lastpage = '<a href="'.$currentPage.'?pageNum_product='.$totalPages_product.$queryString_product.'">Last</a>';
			for ($i=$pluspages-2;$i<=$pluspages+2;$i++) {
				if ($i <= $totalPages_product && $i != 0) {
				$plusone .= '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $i).$queryString_product.'">'.$i.'</a> | ';
				}
			}
		}
	break;
	
	// ---------- search
	case "search":
	$box_content->assign("DATA",'Search Results');
	$firstpage = '<a href="'.$currentPage.'?pageNum_product=1'.$queryString_product.'">First</a> | ';
	$previouspage = '<a href="'.$currentPage.'?pageNum_product='.max(1, $pageNum_product - 1).$queryString_product.'">Previous</a> | ';
	$nextpage = '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $pageNum_product + 2).$queryString_product.'">Next</a> | ';
	$lastpage = '<a href="'.$currentPage.'?pageNum_product='.$totalPages_product.$queryString_product.'">Last</a>';
			for ($i=$pluspages-2;$i<=$pluspages+2;$i++) {
				if ($i <= $totalPages_product && $i != 0) {
				$plusone .= '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $i).$queryString_product.'">'.$i.'</a> | ';
				}
			}
	break;
	
	// ---------- built nav top
	case "categories":
	$box_content->assign("DATA",$navC['name']);
		if ($navOpt[7] == 1) {
		// html perma
		$firstpage = '<a href="'.$installDir['value'].'categoriespage/1/'.$_GET['nc'].'/'.urltxt($navC['name']).'.html">First</a> | ';
		$previouspage = '<a href="'.$installDir['value'].'categoriespage/'.max(1, $pageNum_product).'/'.$_GET['nc'].'/'.urltxt($navC['name']).'.html">Previous</a> | ';
		$nextpage = '<a href="'.$installDir['value'].'categoriespage/'.min($totalPages_product, $pageNum_product + 2).'/'.$_GET['nc'].'/'.urltxt($navC['name']).'.html">Next</a> | ';
		$lastpage = '<a href="'.$installDir['value'].'categoriespage/'.$totalPages_product.'/'.$_GET['nc'].'/'.urltxt($navC['name']).'.html">Last</a>';
			for ($i=$pluspages-2;$i<=$pluspages+2;$i++) {
				if ($i <= $totalPages_product && $i != 0) {
				$plusone .= '<a href="'.$installDir['value'].'categoriespage/'.min($totalPages_product, $i).'/'.$_GET['nc'].'/'.urltxt($navC['name']).'.html">'.$i.'</a> | ';
				}
			}
		} else {
		// php link
		$firstpage = '<a href="'.$currentPage.'?pageNum_product=1'.$queryString_product.'">First</a> | ';
		$previouspage = '<a href="'.$currentPage.'?pageNum_product='.max(1, $pageNum_product).$queryString_product.'">Previous</a> | ';
		$nextpage = '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $pageNum_product + 2).$queryString_product.'">Next</a> | ';
		$lastpage = '<a href="'.$currentPage.'?pageNum_product='.$totalPages_product.$queryString_product.'">Last</a>';
			for ($i=$pluspages-2;$i<=$pluspages+2;$i++) {
				if ($i <= $totalPages_product && $i != 0) {
				$plusone .= '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $i).$queryString_product.'">'.$i.'</a> | ';
				}
			}
		}
	break;
	
	// ---------- built nav sub
	case "subcategories":
	$box_content->assign("DATA",$navB['name'].' '.$navC['name']);
		if ($navOpt[7] == 1) {
		// html perma
		$firstpage = '<a href="'.$installDir['value'].'subcategoriespage/1/'.$_GET['nc'].'/'.$_GET['nb'].'/'.urltxt($navC['name']).'/'.urltxt($navB['name']).'.html">First</a> | ';
		$previouspage = '<a href="'.$installDir['value'].'subcategoriespage/'.max(1, $pageNum_product).'/'.$_GET['nc'].'/'.$_GET['nb'].'/'.urltxt($navC['name']).'/'.urltxt($navB['name']).'.html">Previous</a> | ';
		$nextpage = '<a href="'.$installDir['value'].'subcategoriespage/'.min($totalPages_product, $pageNum_product + 2).'/'.$_GET['nc'].'/'.$_GET['nb'].'/'.urltxt($navC['name']).'/'.urltxt($navB['name']).'.html">Next</a> | ';
		$lastpage = '<a href="'.$installDir['value'].'subcategoriespage/'.$totalPages_product.'/'.$_GET['nc'].'/'.$_GET['nb'].'/'.urltxt($navC['name']).'/'.urltxt($navB['name']).'.html">Last</a>';
			for ($i=$pluspages-2;$i<=$pluspages+2;$i++) {
				if ($i <= $totalPages_product && $i != 0) {
				$plusone .= '<a href="'.$installDir['value'].'subcategoriespage/'.min($totalPages_product, $i).'/'.$_GET['nc'].'/'.$_GET['nb'].'/'.urltxt($navC['name']).'/'.urltxt($navB['name']).'.html">'.$i.'</a> | ';
				}
			}
		} else {
		// php link
		$firstpage = '<a href="'.$currentPage.'?pageNum_product=1'.$queryString_product.'">First</a> | ';
		$previouspage = '<a href="'.$currentPage.'?pageNum_product='.max(1, $pageNum_product).$queryString_product.'">Previous</a> | ';
		$nextpage = '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $pageNum_product + 2).$queryString_product.'">Next</a> | ';
		$lastpage = '<a href="'.$currentPage.'?pageNum_product='.$totalPages_product.$queryString_product.'">Last</a>';
			for ($i=$pluspages-2;$i<=$pluspages+2;$i++) {
				if ($i <= $totalPages_product && $i != 0) {
				$plusone .= '<a href="'.$currentPage.'?pageNum_product='.min($totalPages_product, $i).$queryString_product.'">'.$i.'</a> | ';
				}
			}
		}
	break;
	
	// end switch ->
	}
	
	$box_content->assign("PAGES",($startRow_product+1).' to '.min($startRow_product+$maxRows_product, $totalRows_product).' of '.$totalRows_product);

	if ($totalRows_product > $maxRows_product) {
	$box_content->assign("FIRSTPAGE",$firstpage);
	$box_content->assign("PREVIOUSPAGE",$previouspage);
	$box_content->assign("NEXTPAGE",$nextpage);
	$box_content->assign("PLUSONE",$plusone);
	$box_content->assign("LASTPAGE",$lastpage);
	}
	

}

$box_content->assign("SKIN",$configSkin['value']);
$box_content->parse("pagination");
$box_content = $box_content->text("pagination");
?>